from pathlib import Path

from prompt import DESCRIPTION_PROMPT

ROOT_PATH = Path(__file__).resolve().parent.parent
DATA_PATH = ROOT_PATH / "data"
SRC_PATH = ROOT_PATH / "src"
DESC_PROMPT_FILE = SRC_PATH / "desc_prompt.md"

if __name__ == "__main__":
    top_name = "fft"
    algo_name = "fft_strided"
    category_name = "dsp"
    head_name = DATA_PATH / category_name / algo_name / (algo_name + ".h")
    file_name = DATA_PATH / category_name / algo_name / (algo_name + ".cpp")
    kernel_code: str

    with open(head_name, '+r') as f:
        code = f.read()
        kernel_code = f"```cpp\n{code}\n```\n"
    with open(file_name, '+r') as f:
        code = f.read()
        kernel_code += f"```cpp\n{code}\n```"

    DESCRIPTION_PROMPT = DESCRIPTION_PROMPT.format(
        top_name=top_name,
        kernel_code=kernel_code,
        existing_description=''
    )
    with open(DESC_PROMPT_FILE, '+w') as f:
        f.write(DESCRIPTION_PROMPT)
